package com;

import com.Dao.StudentDao;
import com.Dao.UserDao;
import com.bean.PageInfo;
import com.bean.Student;
import com.bean.User;
import web.MainFrame;

import java.io.IOException;
import java.util.List;

/**
 * @author Lenovo
 * @date 2022/1/5
 */
// 测试类
public class Util {
    public static void testUserDaoQueryUser(){
        UserDao dao = new UserDao();
        List<User> users = dao.queryUser();
        for(User u:users){
            System.out.println(u);
        }
    }

    public static void testStudentDaoQueryStudent(){
        StudentDao dao = new StudentDao();
        int totalNum = dao.queryStudentCount();

        PageInfo pageInfo = new PageInfo();
        pageInfo.setTotal(totalNum);
        List<Student>students;
        System.out.println("=======================================");
        int Pages = pageInfo.getPages();
        for(int page=1;page<=Pages;page++) {
            pageInfo.setPageIndex(page);
            students = dao.queryStudent(pageInfo);
            System.out.println("此时为" + pageInfo.getPageIndex() + "页" + "，有" + students.size() + "行数据");
            System.out.println("当前数据");
            for (Student student : students) {
                System.out.println(student);
            }
            System.out.println("=======================================");
        }
    }

    public static void testUI(){
        new MainFrame();
    }

    public static  void main(String[]args){
        testUI();
    }
}
